package com.huirui.server.controller.mini.program;

import com.huirui.server.pojo.result.Result;
import com.huirui.server.service.FileService;
import com.huirui.server.util.MinioUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping("/api/file")
@Slf4j
@Validated
@Tag(name = "文件管理", description = "微信小程序文件管理相关相关")
public class FileController {

    @Resource
    private FileService fileService;

    @PostMapping("/upload")
    @Operation(summary = "上传文件")
    public Result<String> uploadFile(@RequestParam("file") MultipartFile file) {
        String imageUrl = fileService.uploadFile(file);
        return Result.success(imageUrl);
    }

}
